﻿@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GIS年度税收</title>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }
    </style>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=http://api.map.baidu.com/api?v=2.0&ak=to1sjHDvE74iNOpQsRGHYPuAtXyxMno1"></script>
</head>
<body>
    <div id="allmap"></div>
    <script type="text/javascript">

        var arrMeg = new Array();
        var strMeg;
        var accordionJson, html;
        $(function () {
            getAjax("/Stat/GetAnnualTaskInfo", "", function (data) {
                accordionJson = eval("(" + data + ")");
                $.each(accordionJson, function (i) {

                    strMeg = {
                        lag: accordionJson[i].Dt_BD_Longitude,
                        lng: accordionJson[i].Dt_BD_Latitude,
                        name: accordionJson[i].Dt_Name,
                        residence: accordionJson[i].houNumber,
                        unresidence: accordionJson[i].shopNumber,
                        acceptance: accordionJson[i].ANumber,
                        tax: accordionJson[i].xiaoji
                    };
                    arrMeg.push(strMeg);

                });
            })
        });
        // 获取地图加载数据


        // 百度地图API功能
        var map = new BMap.Map("allmap");          // 创建地图实例
        map.centerAndZoom(new BMap.Point(108.873294, 34.278694), 15); // 创建点坐标
        map.enableScrollWheelZoom();                // 初始化地图，设置中心点坐标和地图级别

        // 根据区域显示覆盖物范围
        function getBoundary() {
            var bdary = new BMap.Boundary();
            bdary.get("陕西省西安市莲湖区", function (rs) {       //获取行政区域
                map.clearOverlays();        					//清除地图覆盖物
                var count = rs.boundaries.length; 				//行政区域的点有多少个
                if (count == 0) {
                    alert('未能获取当前输入行政区域');
                    return;
                }
                var pointArray = [];
                for (var i = 0; i < count; i++) {
                    var ply = new BMap.Polygon(rs.boundaries[i], { strokeWeight: 2, strokeColor: "#33cccc" }); //建立多边形覆盖物
                    map.addOverlay(ply);  						//添加覆盖物
                    pointArray = pointArray.concat(ply.getPath());
                }
                map.setViewport(pointArray);    				//调整视野


                // var aa = mapInfo.split('|');

                //添加莲湖区街道办信息

                for (var i = 0; i < arrMeg.length; i++) {
                    createIco(arrMeg[i]);
                }
            });
        }
        //<img src="~/Content/Images/jieban.png" />
        //创建标注
        function createIco(dome) {

            //创建标注
            var myIcon = new BMap.Icon("../Content/Images/jieban.png", new BMap.Size(32, 32));
            var point = new BMap.Point(dome.lag, dome.lng);
            var marker = new BMap.Marker(point, { icon: myIcon });  // 创建标注
            map.addOverlay(marker);              				//将标注添加到地图中
            marker.setAnimation(BMAP_ANIMATION_DROP); 			//动画

            //设置弹出信息
            var sContent =
            "<h4 style='margin:0 0 5px 0;padding:0.2em 0;font-family:微软雅黑'>" + dome.name + "</h4>" +
            "<div style='float:left;width:220px; height:2px;background:#EE7600;'></div></br>" +
            "<p style='margin:0;line-height:2.0;font-size:13px;'>" +
            "登记住宅数：" + dome.residence + "套</br>" +
            "登记非住宅数：" + dome.unresidence + "套</br>" +
            "受理数：" + dome.acceptance + "套</br>" +
            "征税数：" + ((dome.tax)*0.01).toFixed(2) + "元</br>" +
            "</p>";

            var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
            marker.addEventListener("click", function () {
                map.openInfoWindow(infoWindow, point); 		 //开启信息窗口
            });

            //设置标签
            var label = new BMap.Label(dome.name, { offset: new BMap.Size(30, 2) });
            label.setStyle({
                border: "0px",
                backgroundColor: "#FF8000",
                fontFamily: "微软雅黑",
                fontSize: "14px"
            });
            marker.setLabel(label);
        }

        setTimeout(function () {
            getBoundary();
        }, 1);
    </script>
</body>
</html>